# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php7-pecl-decimal
_pkgreal=decimal
pkgver=2.0.0
pkgrel=1
pkgdesc="Correctly-rounded arbitrary precision decimal floating-point arithmetic in PHP."
url="https://pecl.php.net/package/decimal"
arch="all"
license="MIT"
depends="php7-json"
makedepends="php7-dev re2c mpdecimal"
source="https://pecl.php.net/get/$_pkgreal-$pkgver.tgz
	fix-build.patch
	fix-test.patch
	fix-tests.patch"
builddir="$srcdir/$_pkgreal-$pkgver"
provides="php7-decimal=$pkgver-r$pkgrel" # for backward compatibility
replaces="php7-decimal" # for backward compatibility

build() {
	phpize7
	./configure --prefix=/usr --with-php-config=php-config7
	make
}

check() {
	# waiting upstream release
	rm -f tests/Decimal/operators.phpt tests/Number/operators.phpt tests/Rational/operators.phpt
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test PHP_TEST_SHARED_EXTENSIONS=" \
		-d extension=/usr/lib/php7/modules/json.so \
		-d extension=modules/$_pkgreal.so"
}

package() {
	make INSTALL_ROOT="$pkgdir"/ install
	install -d "$pkgdir"/etc/php7/conf.d
	echo "extension=$_pkgreal.so" > "$pkgdir"/etc/php7/conf.d/$_pkgreal.ini
}

sha512sums="765a2871af38338d1020730936d70c7d493e07c4d0fe6da5b07bf1b5f6bd7ae45239351f9202ced8f579ad1e1c909fbfede1350cc1ec85e0f4cb5f1ef8617cfe  decimal-2.0.0.tgz
8db95e40c19806d2fbb88e8132a3f679f5856ce73548d0b72bb1c806fdb59bfadad0260dd89962f4ac4c41b388d98e8ec988b5bd989e582c9cffc521e832b6d7  fix-build.patch
36d24c2c2fd310d64f6c326ac5241c4732d323608d6dfc7e76d906cd30282e94bdbc5851f1de3e4e2056f005761af52c22afc7a7b672dc4a718f46a74bb75714  fix-test.patch
f972d727fba7bbdf827c2b5ba0cf7588b7e9234f3e5989f06dc92c1a8c34516fdca3e1089e98e3a8c092328a04f524d7d6a0a017869188e219f4bcc1e869a261  fix-tests.patch"
